/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sorts;

/**
 *
 * @author Matias
 */
public class selectionSort extends sort{
    
    public static void sort(int data[], int n)
    // pre: 0 <= n <= data.length
    // post: values in data[0..n-1] are in ascending order
    {
        int numUnsorted = n;
        int index; // general index
        int max; // index of largest value
        while (numUnsorted > 0)
        {
            // determine maximum value in array
            max = 0;
            for (index = 1; index < numUnsorted; index++)
            {
            if (data[max] < data[index]) max = index;
            }
            swap(data,max,numUnsorted-1);
            numUnsorted--;
        }
        for(int i=0 ; i< n ; i++)
            System.out.println(data[i]);
    }

    
    
}
